﻿'Clinciu Andrei
Option Strict On
Imports Gift.BL

Public Class frmFirmDetails

    Private Sub btnOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOk.Click
        Me.DialogResult = Windows.Forms.DialogResult.OK
    End Sub

    'same function as in frmProductEditAdd
    Private Sub btnSearchPic_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearchPic.Click
        ofd.Filter = "Images (*.jpg)|*.jpg|Gif (*.gif)|*.gif"
        ofd.Title = "Kies een afbeelding"

        'get settings from the xml file
        Dim settingsPath As String = My.Application.Info.DirectoryPath & "\settings.xml"
        Dim settings = XDocument.Load(settingsPath)
        Dim imagesFolder As String = settings.<settings>.<imagesFolder>.Value


        ofd.InitialDirectory = CStr(IIf(imagesFolder <> "none", imagesFolder, My.Application.Info.DirectoryPath))

        If ofd.ShowDialog = Windows.Forms.DialogResult.OK Then
            Dim imageFileName As String = System.IO.Path.GetFileName(ofd.FileName)
            If System.IO.File.Exists(ofd.FileName) = True Then
                System.IO.File.Copy(ofd.FileName, imagesFolder & "\" & imageFileName, True)
            End If
            txtAfbeelding.Text = imageFileName
        End If
    End Sub

    Private Sub txtAfbeelding_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtAfbeelding.TextChanged, txtBedrijfnaam.TextChanged, txtBtw.TextChanged, txtPlaats.TextChanged, txtTelefoon.TextChanged
        EnableDisableControls()
    End Sub

    Private Sub EnableDisableControls()
        If txtAfbeelding.Text = "" Or txtBedrijfnaam.Text = "" Or txtBedrijfnaam.Text = "" Or txtPlaats.Text = "" Or txtTelefoon.Text = "" Then
            btnOk.Enabled = False
        Else
            btnOk.Enabled = True
        End If
    End Sub

End Class